Amazon ECS
Get introduced to the Elastic Container Service.
We'll cover the following
General ECS concepts#
Amazon Elastic Container Service (ECS) is a highly scalable and high-performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon EC2 instances. You can use any AMI that meets the Amazon ECS AMI specification.
Amazon ECS eliminates the need for you to install, operate, and scale your own cluster management infrastructure. Using API calls, you can launch and stop container-enabled applications, query the complete state of clusters, and access many familiar features like security groups, Elastic Load Balancing, EBS volumes, and IAM roles.
Amazon ECS can be used to schedule the placement of containers across clusters based on resource needs and availability requirements.
It is possible to use Elastic Beanstalk to handle the provisioning of an Amazon ECS cluster, balancing load, auto-scaling, monitoring, and placing your containers across your cluster. Alternatively, use ECS directly for more fine-grained control for customer application architectures.
It is possible to associate a service on Amazon ECS to an Application Load Balancer (ALB) for the Elastic Load Balancing (ELB) service. The ALB supports a target group that contains a set of instance ports. You can specify a dynamic port in the ECS task definition that gives the container an unused port when it is scheduled on the EC2 instance.
ECS provides Blox, which is a collection of open-source projects for container management and orchestration. Blox makes it easy to consume events from Amazon ECS, store the cluster state locally, and query the local data store through APIs.
Billing
There is no additional charge for Amazon ECS. You pay for the AWS resources (e.g., EC2 instances or EBS volumes) that you create to store and run your application.
ECS vs. EKS#
Amazon also provides the Elastic Container Service for Kubernetes (Amazon EKS), which can be used to deploy, manage, and scale containerized applications using Kubernetes on AWS.
The table below describes some of the differences between these services to help you understand when you might choose one over the other.
| Amazon ECS | Amazon EKS |
|---|---|
| A managed, highly available, and highly scalable container platform | A managed, highly available, and highly scalable container platform |
| AWS-specific platform that supports Docker containers | Compatible with upstream Kubernetes, which makes it easy to lift and shift from other Kubernetes deployments |
| Considered simpler to learn and use | Considered more feature-rich and complex, with a steep learning curve |
| Leverages AWS services like Route 53, ALB, and CloudWatch | A hosted Kubernetes platform that handles many things internally |
| “Tasks” are instances of containers that are run on underlying compute but more or less isolated | “Pods” are containers collocated with one another that can have shared access to each other |
| Limited extensibility | Extensible via a wide variety of third-party and community add-ons |
Launch types#
An Amazon ECS launch type determines the type of infrastructure on which your tasks and services are hosted.
There are two launch types and the table below describes some of the differences between them.
| Amazon EC2 | Amazon Fargate |
|---|---|
| You explicitly provision EC2 instances. | The control plane asks for resources and Fargate automatically provisions. |
| You’re responsible for upgrading, patching, and care of the EC2 pool. | Fargate provisions compute as needed. |
| You must handle cluster optimization. | Fargate handles cluster optimization. |
| More granular control over infrastructure | Limited control, as infrastructure is automated |
Fargate launch type
- The Fargate launch type allows you to run your containerized applications without the need to provision and manage the backend infrastructure. Just register your task definition, and Fargate launches the container for you.
- Fargate launch type is a serverless infrastructure managed by AWS.
- Fargate only supports container images hosted on Elastic Container Registry (ECR) or Docker Hub.
EC2 launch type
- The EC2 launch type allows you to run your containerized applications on a cluster of Amazon EC2 instances that you manage.
- Private repositories are only supported by the EC2 Launch Type.
The following diagram shows the two launch types and summarizes some key differences:
ECS terms
The following table provides an overview of some of the terminology used with Amazon ECS:
| Elastic Container Service (ECS) Term | Description |
|---|---|
| Cluster | Logical grouping of EC2 instances |
| Container instance | EC2 instance running the ECS agent |
| Task definition | Blueprint that describes how a Docker container should launch |
| Task | A running container using settings in a task definition |
| Service | Defines long-running tasks — can control task count with Auto Scaling and attach an ELB |
ASG Behaviour, Configuration, and Monitoring
ECS Properties